Sets the attributes that describe the Modality LUT.
public void SetModalityLut(int frameIndex,DicomModalityLutAttributes attributes,int[] data,DicomSetImageFlags flags)
Public Overloads Sub SetModalityLut( _ByVal frameIndex As Integer, _ByVal attributes As DicomModalityLutAttributes, _ByVal data() As Integer, _ByVal flags As DicomSetImageFlags _)
public void setModalityLut(int frameIndex, DicomModalityLutAttributes attributes, int[]data, int dicomSetImageFlags) public:void SetModalityLut(int frameIndex,DicomModalityLutAttributes^ attributes,array<int>^ data,DicomSetImageFlags flags)
frameIndex
A zero-based index that identifies the frame number in the dataset. If the dataset does not support Multi-frames, this parameter is ignored.
attributes
The Modality LUT attributes to set.
data
Array of integers that holds the "LUT Data".
flags
determines how the modality LUT is stored
This method will set the attributes of the "Modality LUT Module". If you are trying to set the "Rescale Intercept" (0028,1052) and "Rescale Slope" (0028,1053), set IsRescaleSlopeIntercept to true, and populate RescaleIntercept and RescaleSlope with the new values. You can also populate RescaleType if you want to set "Rescale Type" (0028,1054).
If you are trying to set the elements under "Modality LUT Sequence", set IsModalityLutSequence to true, and populate FirstStoredPixelValueMapped, NumberOfEntries, EntryBits, and LutType. In this case, [data](" id="dataparameterlink" class="popuplink.html) should hold the "LUT Data" (0028,3006).
The Multi-frame Functional Groups module may have a Shared Functional Groups Sequence item, and/or a Per-frame Functional Groups Sequence item. Either of these items may have a Pixel Value Transformation Sequence (0028,9145) item. The flags parameter can be used to add or modify existing information in the Pixel Value Transformation Sequence. The following flags are used only if the Pixel Value Transformation Sequence does not already exist.
The specific elements that are read or updated when using these flags are shown below: (0028,9145) Pixel Value Transformation Sequence child elements
| Tag | Name |
| (0028,1052) | Rescale Intercept |
| (0028,1053) | Rescale Slope |
| (0028,1054) | Rescale Type |
For a detailed discussion on Multi-frame Functional Groups see the topic Multi-frame Functional Groups.
This example will initialize a new DICOM command set that supports Multi-frame functional groups Two modality LUT will be added to the dataset at the per frame level The modality LUT from the second frame is retrieved Finally, the modality LUT from the second frame is deleted
using Leadtools;using Leadtools.Dicom;///void DicomDataSet_SetModalityLut2Example(){DicomDataSet ds = new DicomDataSet();DicomDataSetInitializeFlags flags =DicomDataSetInitializeFlags.ExplicitVR |DicomDataSetInitializeFlags.LittleEndian |DicomDataSetInitializeFlags.AddMandatoryElementsOnly |DicomDataSetInitializeFlags.AddMandatoryModulesOnly;// Initialize with class that supports multiframe functional groupsds.Initialize(DicomClassType.EnhancedMRImageStorage, flags);// Delete these items -- they will get added again later in the sample// * Shared Functional Group2 Sequence// * Per-frame Functional Group2 SequenceDicomElement element = ds.FindFirstElement(null, DicomTag.PerFrameFunctionalGroupsSequence, false);if (element != null)ds.DeleteElement(element);element = ds.FindFirstElement(null, DicomTag.SharedFunctionalGroupsSequence, false);if (element != null)ds.DeleteElement(element);// Add a modality LUT on 0th frameDicomModalityLutAttributes modalityLutAttributes = new DicomModalityLutAttributes();modalityLutAttributes.IsModalityLutSequence = false;modalityLutAttributes.IsRescaleSlopeIntercept = true;modalityLutAttributes.RescaleType = "UNSPECIFIED";modalityLutAttributes.RescaleIntercept = -128.0;modalityLutAttributes.RescaleSlope = 1.0;ds.SetModalityLut(0, modalityLutAttributes, null, DicomSetImageFlags.MfgModalityLutPerFrame);// Add a second modality LUT on the 1st framemodalityLutAttributes.RescaleIntercept = -156.0;modalityLutAttributes.RescaleSlope = 1.1;ds.SetModalityLut(1, modalityLutAttributes, null, DicomSetImageFlags.MfgModalityLutPerFrame);// Retrieve the modality LUT attributes from second frame (frameIndex == 1)DicomModalityLutAttributes modalityLutAttributes2 = ds.GetModalityLutAttributes(1);string sMsg = string.Format("Slope: {0}\nIntercept: {1}\nRescaleType {2}",modalityLutAttributes2.RescaleSlope,modalityLutAttributes2.RescaleIntercept,modalityLutAttributes2.RescaleType);MessageBox.Show(sMsg);// Finally, delete the second modality LUTds.DeleteModalityLut(1, DicomSetImageFlags.None);// Save the fileds.Save(Path.Combine(LEAD_VARS.ImagesDir, "Test.dcm"), DicomDataSetSaveFlags.None);}static class LEAD_VARS{public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";}
Imports LeadtoolsImports Leadtools.Dicom'''Private Sub DicomDataSet_SetModalityLut2Example()Dim ds As DicomDataSet = New DicomDataSet()Dim flags As DicomDataSetInitializeFlags = DicomDataSetInitializeFlags.ExplicitVR Or DicomDataSetInitializeFlags.LittleEndian OrDicomDataSetInitializeFlags.AddMandatoryElementsOnly Or DicomDataSetInitializeFlags.AddMandatoryModulesOnly' Initialize with class that supports multiframe functional groupsds.Initialize(DicomClassType.EnhancedMRImageStorage, flags)' Delete these items -- they will get added again later in the sample' * Shared Functional Group2 Sequence' * Per-frame Functional Group2 SequenceDim element As DicomElement = ds.FindFirstElement(Nothing, DicomTag.PerFrameFunctionalGroupsSequence, False)If Not element Is Nothing Thends.DeleteElement(element)End Ifelement = ds.FindFirstElement(Nothing, DicomTag.SharedFunctionalGroupsSequence, False)If Not element Is Nothing Thends.DeleteElement(element)End If' Add a modality LUT on 0th frameDim modalityLutAttributes As DicomModalityLutAttributes = New DicomModalityLutAttributes()modalityLutAttributes.IsModalityLutSequence = FalsemodalityLutAttributes.IsRescaleSlopeIntercept = TruemodalityLutAttributes.RescaleType = "UNSPECIFIED"modalityLutAttributes.RescaleIntercept = -128.0modalityLutAttributes.RescaleSlope = 1.0ds.SetModalityLut(0, modalityLutAttributes, Nothing, DicomSetImageFlags.MfgModalityLutPerFrame)' Add a second modality LUT on the 1st framemodalityLutAttributes.RescaleIntercept = -156.0modalityLutAttributes.RescaleSlope = 1.1ds.SetModalityLut(1, modalityLutAttributes, Nothing, DicomSetImageFlags.MfgModalityLutPerFrame)' Retrieve the modality LUT attributes from second frame (frameIndex == 1)Dim modalityLutAttributes2 As DicomModalityLutAttributes = ds.GetModalityLutAttributes(1)Dim sMsg As String = String.Format("Slope: {0}" & Constants.vbLf & "Intercept: {1}" & Constants.vbLf & "RescaleType {2}",modalityLutAttributes2.RescaleSlope, modalityLutAttributes2.RescaleIntercept, modalityLutAttributes2.RescaleType)MessageBox.Show(sMsg)' Finally, delete the second modality LUTds.DeleteModalityLut(1, DicomSetImageFlags.None)' Save the fileds.Save(Path.Combine(LEAD_VARS.ImagesDir, "Test.dcm"), DicomDataSetSaveFlags.None)End SubPublic NotInheritable Class LEAD_VARSPublic Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"End Class
c#[Silverlight C# Example]using Leadtools;using Leadtools.Dicom;using Leadtools.Examples;void DicomDataSet_SetModalityLut2Example(Stream outputStream){DicomDataSet ds = new DicomDataSet();DicomDataSetInitializeFlags flags =DicomDataSetInitializeFlags.ExplicitVR |DicomDataSetInitializeFlags.LittleEndian |DicomDataSetInitializeFlags.AddMandatoryElementsOnly |DicomDataSetInitializeFlags.AddMandatoryModulesOnly;// Initialize with class that supports multiframe functional groupsds.Initialize(DicomClassType.EnhancedMRImageStorage, flags);// Delete these items -- they will get added again later in the sample// * Shared Functional Group2 Sequence// * Per-frame Functional Group2 SequenceDicomElement element = ds.FindFirstElement(null, DicomTag.PerFrameFunctionalGroupsSequence, false);if (element != null)ds.DeleteElement(element);element = ds.FindFirstElement(null, DicomTag.SharedFunctionalGroupsSequence, false);if (element != null)ds.DeleteElement(element);// Add a modality LUT on 0th frameDicomModalityLutAttributes modalityLutAttributes = new DicomModalityLutAttributes();modalityLutAttributes.IsModalityLutSequence = false;modalityLutAttributes.IsRescaleSlopeIntercept = true;modalityLutAttributes.RescaleType = "UNSPECIFIED";modalityLutAttributes.RescaleIntercept = -128.0;modalityLutAttributes.RescaleSlope = 1.0;ds.SetModalityLut(0, modalityLutAttributes, null, DicomSetImageFlags.MfgModalityLutPerFrame);// Add a second modality LUT on the 1st framemodalityLutAttributes.RescaleIntercept = -156.0;modalityLutAttributes.RescaleSlope = 1.1;ds.SetModalityLut(1, modalityLutAttributes, null, DicomSetImageFlags.MfgModalityLutPerFrame);// Retrieve the modality LUT attributes from second frame (frameIndex == 1)DicomModalityLutAttributes modalityLutAttributes2 = ds.GetModalityLutAttributes(1);string sMsg = string.Format("Slope: {0}\nIntercept: {1}\nRescaleType {2}",modalityLutAttributes2.RescaleSlope,modalityLutAttributes2.RescaleIntercept,modalityLutAttributes2.RescaleType);Debug.WriteLine(sMsg);// Finally, delete the second modality LUTds.DeleteModalityLut(1, DicomSetImageFlags.None);// Save the fileds.Save(outputStream, DicomDataSetSaveFlags.None);}vb[Silverlight VB Example]Imports LeadtoolsImports Leadtools.DicomPrivate Sub DicomDataSet_SetModalityLut2Example(ByVal outputStream As Stream)Dim ds As DicomDataSet = New DicomDataSet()Dim flags As DicomDataSetInitializeFlags = DicomDataSetInitializeFlags.ExplicitVR OrDicomDataSetInitializeFlags.LittleEndian OrDicomDataSetInitializeFlags.AddMandatoryElementsOnly OrDicomDataSetInitializeFlags.AddMandatoryModulesOnly' Initialize with class that supports multiframe functional groupsds.Initialize(DicomClassType.EnhancedMRImageStorage, flags)' Delete these items -- they will get added again later in the sample' * Shared Functional Group2 Sequence' * Per-frame Functional Group2 SequenceDim element As DicomElement = ds.FindFirstElement(Nothing, DicomTag.PerFrameFunctionalGroupsSequence, False)If Not element Is Nothing Thends.DeleteElement(element)End Ifelement = ds.FindFirstElement(Nothing, DicomTag.SharedFunctionalGroupsSequence, False)If Not element Is Nothing Thends.DeleteElement(element)End If' Add a modality LUT on 0th frameDim modalityLutAttributes As DicomModalityLutAttributes = New DicomModalityLutAttributes()modalityLutAttributes.IsModalityLutSequence = FalsemodalityLutAttributes.IsRescaleSlopeIntercept = TruemodalityLutAttributes.RescaleType = "UNSPECIFIED"modalityLutAttributes.RescaleIntercept = -128.0modalityLutAttributes.RescaleSlope = 1.0ds.SetModalityLut(0, modalityLutAttributes, Nothing, DicomSetImageFlags.MfgModalityLutPerFrame)' Add a second modality LUT on the 1st framemodalityLutAttributes.RescaleIntercept = -156.0modalityLutAttributes.RescaleSlope = 1.1ds.SetModalityLut(1, modalityLutAttributes, Nothing, DicomSetImageFlags.MfgModalityLutPerFrame)' Retrieve the modality LUT attributes from second frame (frameIndex == 1)Dim modalityLutAttributes2 As DicomModalityLutAttributes = ds.GetModalityLutAttributes(1)Dim sMsg As String = String.Format("Slope: {0}" _& Constants.vbLf _& "Intercept: {1}" _& Constants.vbLf _& "RescaleType {2}",modalityLutAttributes2.RescaleSlope,modalityLutAttributes2.RescaleIntercept,modalityLutAttributes2.RescaleType)Debug.WriteLine(sMsg)' Finally, delete the second modality LUTds.DeleteModalityLut(1, DicomSetImageFlags.None)' Save the fileds.Save(outputStream, DicomDataSetSaveFlags.None)End Sub
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
